#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mid (l+r>>1LL)
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define pb push_back
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57){if(c=='-')w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
const int N=5e5+5,M=2e7+5,inf=(1LL<<30)-1,mod=1e9+7;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
#define L x<<1
#define R x<<1|1
#define lc L,l,mid
#define rc R,mid+1,r
#define OK Ll<=l&&r<=Rr
bool S;
struct move{
	int x,k;
}sl[M],sr[M];
int tpl,tpr,tl[N<<1],tr[N<<1],n,m=1000000,out[N];
inline void adr(int x,int l){
	while(x<=m){
		if(l>tr[x])sr[++tpr]={x,tr[x]},tr[x]=l;
		x+=x&-x;
	}
}
inline int queryr(int x){int ans=-inf;while(x)ans=max(ans,tr[x]),x-=x&-x;return ans;}
inline void adl(int x,int r){
	x=m-x+1;
	while(x<=m){
		if(r<tl[x])sl[++tpl]={x,tl[x]},tl[x]=r;
		x+=x&-x;
	}
}
inline int queryl(int x){x=m-x+1;int ans=inf;while(x)ans=min(ans,tl[x]),x-=x&-x;return ans;}
map<int,int>P[N<<1],Q[N<<1];
inline void delP(int x,int r){
	if(!--P[x][r])P[x].erase(r);
}
inline void delQ(int x,int l){
	if(!--Q[x][-l])Q[x].erase(-l);
}
map<Pi,vector<int>>G;
vector<Pi>g[N<<2];
#define Root 1,1,n
void modify(int x,int l,int r,int Ll,int Rr,Pi i){
	if(OK)return g[x].pb(i),void();
	if(Ll<=mid)modify(lc,Ll,Rr,i);
	if(Rr>mid)modify(rc,Ll,Rr,i);
}
int Mxl,Mnr,Mnlen;
void dfs(int x,int l,int r){
	int pml=Mxl,pmr=Mnr,prl=tpl,prr=tpr,pl=Mnlen;
	for(auto y:g[x]){
		Mxl=max(Mxl,y.first),Mnr=min(Mnr,y.second);
		adr(y.second,y.first),adl(y.first,y.second),P[y.first][y.second]++,Q[y.second][-y.first]++;
		Mnlen=min({Mnlen,y.second-queryr(y.first-1)+1,queryl(y.second+1)-y.first+1});
	}
	if(l==r){	
		if(Mnr>=Mxl)out[l]=(*P[Mxl].begin()).first+(*Q[Mnr].begin()).first+1;
		else out[l]=Mnlen;
	}else dfs(lc),dfs(rc);
	Mxl=pml,Mnr=pmr,Mnlen=pl;
	while(tpl>prl)tl[sl[tpl].x]=sl[tpl].k,tpl--;
	while(tpr>prr)tr[sr[tpr].x]=sr[tpr].k,tpr--;
	for(auto y:g[x])delP(y.first,y.second),delQ(y.second,y.first);
}
inline void Main(){
	n=read();
	repn(i){
		char opt;
		cin>>opt;
		int l=read(),r=read()-1;
		if(opt=='A')G[{l,r}].pb(i);
		else {
			modify(Root,G[{l,r}].back(),i-1,{l,r});
			G[{l,r}].pop_back();
		}
	}
	// cerr<<(double)clock()/CLOCKS_PER_SEC<<"seconds.\n";
	for(auto x:G)for(auto i:x.second)modify(Root,i,n,x.first);
	// cerr<<(double)clock()/CLOCKS_PER_SEC<<"seconds.\n";
	repm(x)tr[x]=-inf,tl[x]=inf;
	Mnr=m+1,Mnlen=inf,dfs(Root);
	// cerr<<(double)clock()/CLOCKS_PER_SEC<<"seconds.\n";
	repn(i)printf("%d\n",out[i]);
}
bool E;
signed main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	// cerr<<"[Memory]"<<(&E-&S)/1024/1024<<"MB.\n";
	int T=1;
	while(T--)Main();
	return 0;
}